package com.example.websocketdemo.controller;

import com.alibaba.fastjson.JSONObject;
import com.example.websocketdemo.config.WebSocketTest;
import jdk.nashorn.internal.ir.RuntimeNode;
import org.apache.catalina.connector.Response;
import org.omg.CORBA.Request;
import org.springframework.stereotype.Repository;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.FilterChain;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;

@RestController
@RequestMapping("/EmergencyManagement")
public class EmergencyManagementController {
    @GetMapping("/monitoring")
    public void monitoring(HttpServletResponse response) throws IOException {
        response.setHeader("Access-Control-Allow-Origin", "*");
        JSONObject jsonObject_one = new JSONObject();
        jsonObject_one.put("instruction","resetpoi");
        WebSocketTest.sendInfo(jsonObject_one.toJSONString(), "connect");
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("MenuName","EmergencyManagement");
        jsonObject.put("ButtonName","monitoring");
        System.out.println("123456");
        WebSocketTest.sendInfo(jsonObject.toJSONString(), "connect");
    }

    @GetMapping("/emergencySupplies")
    public void emergencySupplies(HttpServletResponse response) throws IOException {
        response.setHeader("Access-Control-Allow-Origin", "*");
        JSONObject jsonObject_one = new JSONObject();
        jsonObject_one.put("instruction","resetpoi");
        WebSocketTest.sendInfo(jsonObject_one.toJSONString(), "connect");
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("MenuName","EmergencyManagement");
        jsonObject.put("ButtonName","emergencySupplies");
        WebSocketTest.sendInfo(jsonObject.toJSONString(), "connect");
    }
}
